<%@page import="br.com.Modelo.UsuarioCliente"%>
<%@page import="br.com.Modelo.UsuarioComerciante"%>
<%@page import="br.com.Modelo.Pagina"%>
<%@page import="br.com.Modelo.Produto"%>
<%@page import="br.com.Modelo.Endereco"%>
<%@page import="br.com.Dao.UsuarioClienteDao"%>
<%@page import="br.com.Dao.UsuarioComercianteDao"%>
<%@page import="java.io.IOException"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Mercado Catalão</title>
<!-- Bootstrap Core CSS -->

<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
<style type="text/css">
.topo {
	width: 100%;
	height: 260px;
	margin-bottom: 20px;
	margin-top: -20px;
}

body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}

#banner {
	margin-top: 20px;
	margin-left: 340px;
	border: 2px solid #eee;
}

#box {
	transition: all 0.4s linear;
	-webkit-transition: all 0.4s linear;
	-moz-transition: all 0.4s linear;
	-o-transition: all 0.4s linear;
	-ms-transition: all 0.4s linear;
	opacity: 1;
}

#box:hover {
	/*box-shadow: 0 1px 15px #777;*/
	box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 5px 2px;
	background: rgba(200, 200, 200, 0.1);
	cursor: pointer;
}

.panel-footer a {
	font-size: 25px;
}


.well {
    margin-top:-1px;
    /*background-color:#007FBD;*/
   /* border:1px solid #0077B2; */
    text-align:center;
    cursor:pointer;
    font-size: 25px;
    padding: 2px;
   /* border-radius: 0px !important;*/
    
}

.well:hover {
   /* margin-top:-20px;*/
    /*background-color:#0077B2;*/
   /* border:1px solid #0077B2;*/
    text-align:center;
    cursor:pointer;
    font-size: 25px;
    padding: 2px;
    border-radius: 0px !important;
    border-bottom : 1px solid rgba(97, 203, 255, 0.65);
}

#img{
 height: 100px;
 
  }

</style>



</head>

<body>

	<%
		//allow access only if session exists
		
	//	out.print(request.getParameter("page"));
	  //  out.println(request.getAttribute("pagina"));
	  //  out.println(request.getAttribute("id_pagina"));
		String[] id= (String[]) session.getAttribute("user");
		UsuarioCliente userCliente = null;
		UsuarioComerciante userComerciante = null;
		UsuarioClienteDao dao = new UsuarioClienteDao();
		UsuarioComercianteDao dao1 = new UsuarioComercianteDao();
		if(id != null){
			//out.print(id[0]+"->"+id[1]);
			if(id[1].equals("1")){
			
		userCliente = dao.validaAutenticacaoUser(Long.parseLong(id[0]), Integer.parseInt(id[1]));
			
			}else{
		
		userComerciante = dao1.validaAutenticacaoUser(Long.parseLong(id[0]), Integer.parseInt(id[1]));
			}
		}
		String userName = null;
		String sessionID = null;
		Cookie[] cookies = request.getCookies();
		if(cookies !=null){
		for(Cookie cookie : cookies){
			if(cookie.getName().equals("user")) userName = cookie.getValue();
			if(cookie.getName().equals("JSESSIONID")) sessionID = cookie.getValue();
		}
			}
		if(userCliente != null || userComerciante != null){
			if(userCliente == null){
		//out.print("Login : "+userComerciante.getLogin());
			}else{
		//out.print("Login : "+userCliente.getLogin());			
			}
			
		}
	%>



	<%@ include file="../menu.jsp"%>
	
	<%  
	    
	  Pagina pagina = new Pagina();
	  pagina = (Pagina)request.getAttribute("pagina");
	  
	 
	  
	   if(pagina != null){
	
	%>
	<script>
		//document.write(window.location.pathname);
	</script>
	<!-- cabeçalho -->
	<!-- estrutura -->


	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span2">
				<!--Sidebar content-->
				<div class="col-md-3" align="left">
					<div class="panel panel-default">
					
					<div class="panel-heading " style="padding: 10px;">    
						   <span class="glyphicon glyphicon-comment"></span>
						Descriçao sobre a loja
						
				   </div>
						<div class="panel-body">
						 <% if(pagina != null){
							 int cont=0;
						    for(Endereco end : pagina.getEnds()){
						 
						 %>	
						   
							<address>
							   <%if(cont==0){%>
								<h4><strong><%=pagina.getUsuarioComerciante().getNome()%></strong></h4><% cont++;} %><br> 
								<strong>CEP:</strong> <%=end.getCep()%><br/>
								<strong>Cidade:</strong> <%=end.getCidade()%><br/>
								<strong>Bairro:</strong> <%=end.getBairro()%></br>
								<strong>Rua, N°:</strong><%=end.getRua()%>,<%=end.getNumero()%><br> <span
									class="glyphicon glyphicon-earphone"></span> <abbr
									title="Phone">Telefone:</abbr> <%=end.getTelefone() %>
							</address>
							<hr/>
							<% if(cont == pagina.getEnds().size()) {%>
							
							<address>
								<strong>Email</strong><br> <a href="mailto:#">ClickCatalao@hotmail.com</a>
							</address>
							<%} %>
							<% cont++;}
						 }
						    %>
						</div>
						
					
					</div>
				</div>
			</div>
			<div class="span10">
				<!--Body content-->
				<div class="topo">
					<div id="banner">
<!--  img/clickcatalao/bannerclick.jpg-->
                    <% if(pagina != null){ %>
						<img src="img/<%=pagina.getImgPagina()%>" align="bottom"
							height="280px" width="100%">
                          <div class="panel-footer " style="padding: 10px;">                               
                     <% } %>          
           				   <a href="" style="padding: 10px;" ><span class="fa fa-thumbs-o-up fa-lg" class="well"></span> 26</a>
           						 <a href="#download" style="padding: 10px;"><span class="glyphicon glyphicon-download" class="well" ></span></a>
                                 <a href="#facebook"style="padding: 10px;" class="img-ico"><span class="fa fa-facebook" class="well"></span></a>
                       </div>
					</div>


					<div class="col-md-9">
						<div class="page-header">
							<h3>Produtos</h3>
						</div>

		<%
		    if(pagina != null){
		
			for (Produto produto : pagina.getProduto()) {
		%> 
		<div class="col-md-3">
			<div class="thumbnail" id="box">
				<img id="img"  src="/plataforma_marketing/img/product/<%=produto.getImagem_produto()%>" width="100px" height="80px"
					alt="..." />
				<div class="caption" id="box2">
					<h4><%=produto.getNome_produto()%></h4>
					
					<% 
					if(produto.getPreco_promocao_produto() == 0){				
						%>
						
					<p><b><font color="#357ebd" size="+2">Por:R$ <%=produto.getPreco_normal_produto()%></font></b></p>
					<% 
						}
					else{
					%>
						<p><font color="#888">De:R$ <%=produto.getPreco_normal_produto()%></font><br />
						<b><font color="#357ebd" size="+2">Por:R$ <%=produto.getPreco_promocao_produto()%></font></b></p>
					<% 
						}
					%>						
					<p>
						<a href="products/<%=pagina.getPagina()%>/<%=produto.getId_produto()%>"
							class="btn btn-primary" role="button" data-toggle=""
							data-target="">Detalhes</a> <a
							href=""
							class="btn btn-default" role="button">Loja</a>
					</p>
				</div>
			</div>
		</div>
		<%
			}
		    }
		%>
		
		
	
					<!-- 	<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
									
						                
								</div>
							</div>
						</div>


                         
                         
                         
						<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
								</div>
							</div>
						</div>

						<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
								</div>
							</div>
						</div>

						<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
								</div>
							</div>
						</div>

						<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
								</div>
							</div>
						</div>

						<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
								</div>
							</div>
						</div>

						<div class="col-md-3">
							<div class="thumbnail" id="box">
								<img src="http://renswijnmalen.nl/bootstrap/desktop_mobile.png"
									alt="..." />
								<div class="caption">
									<h3>Thumbnail label</h3>
									<p>...</p>
									<p>
										<a href="#" type="button" class="btn btn-primary">Button</a> <a
											href="#" class="btn btn-default" role="button">Button</a>
									</p>
								</div>
							</div>
						</div>

					</div>
					-->

				</div>
			</div>
		</div>
	</div>



   <%}else{ %>


     <div style="padding:10;margin:0 auto;width:80%;font-size:28;margin-top:100px; text-align:center; height : 254px; ">
      
      
     <br/> <h1> Pagina em criação </h1>
        
       <hr> <a href="/plataforma_marketing"> <h2>volta pagina inicial</h2></a>
    
    </div>
    <%} %>

<!-- jQuery Version 1.11.0 -->
	<script src="/plataforma_marketing/bootstrap/js/jquery-1.11.0.js"></script>
	<script src="/plataforma_marketing/bootstrap/js/bootstrap.js"></script>



</body>
</html>